package upmc.fr.android.rss.listener;

import java.util.ArrayList;

import android.app.Activity;
import android.content.Intent;
import android.view.View;
import android.view.View.OnClickListener;

public class ListenerShare implements OnClickListener{

	private Activity parentActivity;
	private ArrayList<String> strings;


	/**
	 * Constructeur
	 */
	public ListenerShare (Activity parentActivity, ArrayList<String> arrayList) {
		this.parentActivity = parentActivity;
		this.strings = arrayList;	
	}

	
	@Override
	public void onClick(View v) {
		share();
	}

	public void share(){
		final Intent sharingIntent = new Intent(Intent.ACTION_SEND);
		String chaine = "";
		sharingIntent.setType("text/plain");
		sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, strings.get(0));
		for(int ligne = 1; ligne < strings.size(); ligne++)
			chaine+=strings.get(ligne)+"\n";
		sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT,chaine);
		parentActivity.startActivity(Intent.createChooser(sharingIntent, "Share using"));
	}
}
